package studentmsg

// StudentMsg 是用于存放学生信息的结构体.
type StudentMsg struct {
	name          string
	id            string
	chineseGrades int
	mathGrades    int
	englishGrades int
	next          *StudentMsg
	previous      *StudentMsg
}

// Init 用于初始化StudentMsg结构体.
func (s *StudentMsg) Init(name string, id string, chineseGrades int, mathGrades int, englishGrades int) {
	s.name = name
	s.id = id
	s.chineseGrades = chineseGrades
	s.mathGrades = mathGrades
	s.englishGrades = englishGrades
	s.next = nil
	s.previous = nil
}

// copy 用于复制一个StudentMsg结构，不改变原来的结构内数据
func (s *StudentMsg) copy() *StudentMsg {
	var newOne StudentMsg = StudentMsg{}
	newOne.Init(
		s.name,
		s.id,
		s.chineseGrades,
		s.mathGrades,
		s.englishGrades,
	)
	newOne.next = s.next
	newOne.previous = s.previous
	return &newOne
}

// GetName 用于获取学生姓名
func (s *StudentMsg) GetName() string {
	return s.name
}

// GetID is used to get student's id.
func (s *StudentMsg) GetID() string {
	return s.id
}

// GetGrades is used to get student's chinese, math and english grades.
func (s *StudentMsg) GetGrades() (chineseGrades int, mathGrades int, englishGrades int) {
	return s.chineseGrades, s.mathGrades, s.englishGrades
}
